#pragma once
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<assert.h>
using namespace std;
namespace bit
{
	using iterator = char*;
	using const_iterator = const char*;
	class string
	{
	public:
		string(const char* str = "");
		string(const string& str);
		~string();
		size_t size() const;
		char& operator[](size_t pos);
		const char& operator[](size_t pos) const;
		char* c_str() const;
		iterator begin();
		iterator end();
		const_iterator begin() const;
		const_iterator end() const;
		void reverse(size_t n);
		void push_back(char ch);
		void append(const char* str);
		void insert(size_t pos, char ch);
		void insert(size_t pos, const char* str);
		void erase(size_t pos, size_t len = npos);
		size_t find(size_t pos, char ch) const;
		size_t find(const char* str, size_t pos) const;
		string substr(size_t pos, size_t len = npos);
		void swap(string& s);
		void clear();
		string& operator+=(char ch);
		string& operator+=(const char* str);
		string& operator= (string s);
		
	private:
		char* _str;
		size_t _size;
		size_t _capacity;
	public:
		static const size_t npos = -1;
	};
	ostream& operator<<(ostream& os, const string& str);
	istream& operator>>(istream& is, string& str);
	istream& getline(istream& is, string& str, char delim = '\n');
	void swap(string& s1, string& s2);
}